package com.simin.base.appview;

import android.content.Context;
import android.util.AttributeSet;

/**
 * Created by wsm on 2024/9/18.
 * <p>
 */
public class NestedScrollView extends androidx.core.widget.NestedScrollView {

    private ScrollViewListener scrollViewListener = null;

    public NestedScrollView(Context context) {
        super(context);
    }

    public NestedScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setScrollViewListener(ScrollViewListener scrollViewListener) {
        this.scrollViewListener = scrollViewListener;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (scrollViewListener != null) {
            scrollViewListener.onScrollChanged(this, l, t, oldl, oldt);
        }
    }

    public interface ScrollViewListener {
        void onScrollChanged(NestedScrollView scrollView, int l, int t, int oldl, int oldt);
    }
}
